@include('admin.public.head')

<div class="ibox-title">
    <h5>審核充值</h5>
</div>

<div class="ibox-content">
    <form  class="form-horizontal">

{{--        <div class="form-group">
            <label class="col-sm-3 control-label">門店分類：</label>
            <div class="col-sm-9">
                <select class="form-control" name="store_id" id="store_id">
                    <option value="" >請選擇門店</option>
                    @foreach($select_store as $k=>$v)
                        <option value="{{$k}}" @if($select_id == $k) selected="selected" @endif>{{$v}}</option>
                    @endforeach
                </select>
            </div>
        </div>--}}
        <div class="hr-line-dashed"></div>


        <div class="form-group">
            <label class="col-sm-3 control-label">套餐名称：</label>
            <div class="col-sm-9">
                <input type="text" name="title" class="form-control" placeholder="套餐名称" value="{{$result->integral_plan->title??''}}" readonly="readonly">
            </div>
        </div>
        <div class="hr-line-dashed"></div>


        <div class="form-group">
            <label class="col-sm-3 control-label">用戶ID：</label>
            <div class="col-sm-9">
                <input type="text" name="user_id" class="form-control" placeholder="用戶ID" value="{{$result->user_id??''}}" readonly="readonly">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">用戶名稱：</label>
            <div class="col-sm-9">
                <input type="text" name="nickname" class="form-control" placeholder="用戶名稱" value="{{$result->user->nickname??''}}" readonly="readonly">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">用戶頭像：</label>
            <div class="col-sm-9">
                {{--<input type="file" name="teacher_head" class="form-control"  value="" readonly="readonly">--}}
                <img src="{{$result->user->head_img??''}}" width="300" height="150">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">積分：</label>
            <div class="col-sm-9">
                <input type="text" name="integral" class="form-control" placeholder="積分" value="{{$result->integral??''}}" readonly="readonly">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">證明：</label>
            <div class="col-sm-9">
               {{-- <input type="file" name="proof_img" class="form-control"  value="" readonly="readonly">--}}
                <img src="{{$result->proof_img??''}}" width="300" height="150">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">审核状态：</label>
            <div class="col-sm-9">
                <select class="form-control" name="status" id="status">
                 {{--  // <option value="" >請選擇</option>--}}

                        <option value="1" @if($result->status == 1) selected="selected" @endif>待审核</option>

                        <option value="2" @if($result->status == 2) selected="selected" @endif>通过</option>

                        <option value="3" @if($result->status == 3) selected="selected" @endif>拒绝</option>
                </select>
            </div>
        </div>
        <div class="hr-line-dashed"></div>


        <input type="hidden" name="id" value="{{$id??0}}">

        <div class="form-group">
            <div class="col-sm-4 col-sm-offset-3">
                <button class="btn btn-primary do" type="submit">操作</button>
                <a href="/user_integral" class="btn btn-primary" >返回申請列表</a>
            </div>
        </div>
    </form>
</div>

<script>
    $('.do').click(function(){
        var form = new FormData();

        var status = $('#status option:selected').val();
        var id = $('input[name="id"]').val();
        var user_id = $('input[name="user_id"]').val();
        var integral = $('input[name="integral"]').val();

        form.append("user_id", user_id);
        form.append("status", status);
        form.append("id", id);
        form.append("integral", integral);

        $.ajax({
            type: 'POST',
            url: '/user_integral_do' ,
            dataType:"json",   //返回格式为json
            data: form ,
            processData: false,
            contentType: false,
            success:function(data){

                if(data.status == '1') {
                    var swal_json = {
                        title: data.message,
                        type: "success"
                    }

                    swal(swal_json, function (isConfirm) {
                        window.location.reload();
                    });

                }else{
                    var swal_json = {
                        title: data.message,
                        type: "error"
                    }

                    swal(swal_json, function (isConfirm) {

                    });
                }
            }
        });

        return false;
    });

</script>
